<?PHP
require_once WACT_ROOT . 'util/dataspace.inc.php';
require_once WACT_ROOT . 'controller/responsemodel.inc.php';
//require_once APP_ROOT . 'model/common/user.php';

class Session {

	// saves response model into session
	function saveResponseModel(&$rs,$name) {
			$properties =& $rs->export();

			$_SESSION[$name]=$properties;
	}

    // loads response model from session
    // and merges with the current responseModel
	function loadResponseModel(&$rs,$name) {
            if( isset($_SESSION[$name]) ) {
            		$properties = $_SESSION[$name];
            		//print 'Restored filter';
            		//print_r( $properties );
            		$rs->merge($properties);
            }
   	}



	function setUser($user){
		$properties=$user->getPropertyList();
		foreach ($properties as $index=>$property){
			if($property!='password')
				$userArray[$property]=$user->get($property);
		}
		$_SESSION['USER']=$userArray;
	}

	function isLogin(){
		if(isset($_SESSION['USER'])){
			$user=$_SESSION['USER'];
			if(isset($user['login']))
				return true;
		}
		return false;
	}

	function getUserId(){
		$user=$_SESSION['USER'];
		return $user['user_id'];
	}

	function removeUser(){
		$_SESSION['USER']=null;

	}

	function &getUserArray(){
		return  $_SESSION['USER'];
	}
}
?>
